EC-CUBE 2.11.4
[ class tree: EC-CUBE 2.11.4 ] [ index: EC-CUBE 2.11.4 ] [ all elements ]

Source for file SC_View.php

Documentation is available at SC_View.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.lockon.co.jp/
  8.  *
  9.  * This program is free software; you can redistribute it and/or
  10.  * modify it under the terms of the GNU General Public License
  11.  * as published by the Free Software Foundation; either version 2
  12.  * of the License, or (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  22.  */
  23.  
  24. require_once realpath(dirname(__FILE__)) . '/../module/Smarty/libs/Smarty.class.php';
  25.  
  26. class SC_View {
  27.  
  28.     var $_smarty;
  29.  
  30.     // コンストラクタ
  31.     function SC_View($siteinfo = true) {
  32.  
  33.         $this->_smarty = new Smarty;
  34.         $this->_smarty->left_delimiter = '<!--{';
  35.         $this->_smarty->right_delimiter = '}-->';
  36.         $this->_smarty->register_modifier('sfDispDBDate', array("SC_Utils_Ex", 'sfDispDBDate'));
  37.         $this->_smarty->register_modifier('sfConvSendDateToDisp', array("SC_Utils_Ex", 'sfConvSendDateToDisp'));
  38.         $this->_smarty->register_modifier('sfConvSendWdayToDisp', array("SC_Utils_Ex", 'sfConvSendWdayToDisp'));
  39.         $this->_smarty->register_modifier('sfGetVal', array("SC_Utils_Ex", 'sfGetVal'));
  40.         $this->_smarty->register_modifier('sfGetErrorColor', array("SC_Utils_Ex", 'sfGetErrorColor'));
  41.         $this->_smarty->register_modifier('sfTrim', array("SC_Utils_Ex", 'sfTrim'));
  42.         $this->_smarty->register_modifier('sfCalcIncTax', array("SC_Helper_DB_Ex", 'sfCalcIncTax'));
  43.         $this->_smarty->register_modifier('sfPrePoint', array("SC_Utils_Ex", 'sfPrePoint'));
  44.         $this->_smarty->register_modifier('sfGetChecked',array("SC_Utils_Ex", 'sfGetChecked'));
  45.         $this->_smarty->register_modifier('sfTrimURL', array("SC_Utils_Ex", 'sfTrimURL'));
  46.         $this->_smarty->register_modifier('sfMultiply', array("SC_Utils_Ex", 'sfMultiply'));
  47.         $this->_smarty->register_modifier('sfPutBR', array("SC_Utils_Ex", 'sfPutBR'));
  48.         $this->_smarty->register_modifier('sfRmDupSlash', array("SC_Utils_Ex", 'sfRmDupSlash'));
  49.         $this->_smarty->register_modifier('sfCutString', array("SC_Utils_Ex", 'sfCutString'));
  50.         $this->_smarty->plugins_dir=array('plugins', realpath(dirname(__FILE__)) . "/../smarty_extends");
  51.         $this->_smarty->register_modifier('sfMbConvertEncoding', array("SC_Utils_Ex", 'sfMbConvertEncoding'));
  52.         $this->_smarty->register_modifier('sfGetEnabled', array("SC_Utils_Ex", 'sfGetEnabled'));
  53.         $this->_smarty->register_modifier('sfGetCategoryId', array("SC_Utils_Ex", 'sfGetCategoryId'));
  54.         $this->_smarty->register_modifier('sfNoImageMainList', array("SC_Utils_Ex", 'sfNoImageMainList'));
  55.         // XXX register_function で登録すると if で使用できないのではないか?
  56.         $this->_smarty->register_function('sfIsHTTPS', array("SC_Utils_Ex", 'sfIsHTTPS'));
  57.         $this->_smarty->register_function('sfSetErrorStyle', array("SC_Utils_Ex", 'sfSetErrorStyle'));
  58.         $this->_smarty->register_function('printXMLDeclaration', array("SC_Utils_Ex", 'printXMLDeclaration'));
  59.         $this->_smarty->default_modifiers = array('script_escape');
  60.  
  61.         if(ADMIN_MODE == '1') {
  62.             $this->time_start = SC_Utils_Ex::sfMicrotimeFloat();
  63.         }
  64.     }
  65.  
  66.     // テンプレートに値を割り当てる
  67.     function assign($val1, $val2) {
  68.         $this->_smarty->assign($val1, $val2);
  69.     }
  70.  
  71.     // テンプレートの処理結果を取得
  72.     function fetch($template, $no_error=false) {
  73.         return $this->_smarty->fetch($template);
  74.     }
  75.  
  76.     /**
  77.      * SC_Display用にレスポンスを返す
  78.      * @global string $GLOBAL_ERR 
  79.      * @param array $template 
  80.      * @param boolean $no_error 
  81.      * @return string 
  82.      */
  83.     function getResponse($template, $no_error = false) {
  84.         if(!$no_error) {
  85.             global $GLOBAL_ERR;
  86.             if(!defined('OUTPUT_ERR')) {
  87.                 // GLOBAL_ERR を割り当て
  88.                 $this->assign("GLOBAL_ERR", $GLOBAL_ERR);
  89.                 define('OUTPUT_ERR','ON');
  90.             }
  91.         }
  92.         $res =  $this->_smarty->fetch($template);
  93.         if(ADMIN_MODE == '1') {
  94.             $time_end = SC_Utils_Ex::sfMicrotimeFloat();
  95.             $time = $time_end - $this->time_start;
  96.             $res .= '処理時間: ' . sprintf('%.3f', $time) . '秒';
  97.         }
  98.         return $res;
  99.     }
  100.  
  101.     // テンプレートの処理結果を表示
  102.     function display($template, $no_error = false) {
  103.         if(!$no_error) {
  104.             global $GLOBAL_ERR;
  105.             if(!defined('OUTPUT_ERR')) {
  106.                 // GLOBAL_ERR を割り当て
  107.                 $this->assign("GLOBAL_ERR", $GLOBAL_ERR);
  108.                 define('OUTPUT_ERR','ON');
  109.             }
  110.         }
  111.  
  112.         $this->_smarty->display($template);
  113.         if(ADMIN_MODE == '1') {
  114.             $time_end = SC_Utils_Ex::sfMicrotimeFloat();
  115.             $time = $time_end - $this->time_start;
  116.             echo '処理時間: ' . sprintf('%.3f', $time) . '秒';
  117.         }
  118.     }
  119.  
  120.     // オブジェクト内の変数をすべて割り当てる。
  121.     function assignobj($obj) {
  122.         $data = get_object_vars($obj);
  123.  
  124.         foreach ($data as $key => $value){
  125.             $this->_smarty->assign($key, $value);
  126.         }
  127.     }
  128.  
  129.     // 連想配列内の変数をすべて割り当てる。
  130.     function assignarray($array) {
  131.         foreach ($array as $key => $val) {
  132.             $this->_smarty->assign($key, $val);
  133.         }
  134.     }
  135.  
  136.     /* サイト初期設定 */
  137.     function initpath() {
  138.  
  139.         $array['tpl_mainnavi'] = realpath(dirname(__FILE__)) . '/../Smarty/templates/frontparts/mainnavi.tpl';
  140.  
  141.         $objDb = new SC_Helper_DB_Ex();
  142.         $array['tpl_root_id'] = $objDb->sfGetRootId();
  143.         $this->assignarray($array);
  144.     }
  145.  
  146.     /**
  147.      * テンプレートパスをアサインする.
  148.      *
  149.      * @param integer $device_type_id 端末種別ID
  150.      */
  151.     function assignTemplatePath($device_type_id) {
  152.  
  153.         // テンプレート変数を割り当て
  154.         $this->assign("TPL_URLPATH", SC_Helper_PageLayout_Ex::getUserDir($device_type_id, true));
  155.  
  156.         // ヘッダとフッタを割り当て
  157.         $templatePath = SC_Helper_PageLayout_Ex::getTemplatePath($device_type_id);
  158.         $header_tpl = $templatePath . "header.tpl";
  159.         $footer_tpl = $templatePath . "footer.tpl";
  160.  
  161.         $this->assign("header_tpl", $header_tpl);
  162.         $this->assign("footer_tpl", $footer_tpl);
  163.     }
  164.  
  165.     // デバッグ
  166.     function debug($var = true){
  167.         $this->_smarty->debugging = $var;
  168.     }
  169. }
  170.  
  171. ?>

Documentation generated on Fri, 24 Feb 2012 14:03:04 +0900 by Seasoft